package com.qqgame.hlddz;

import android.app.ActivityOptions;
import android.content.ComponentName;
import android.content.Intent;
import android.net.Uri;
import android.os.Bundle;
import android.widget.Toast;

import androidx.appcompat.app.AppCompatActivity;

public class NaviPreviewActivity extends AppCompatActivity {

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);

        try {
            ActivityOptions options = ActivityOptions.makeBasic();
            options.setLaunchDisplayId(MainActivity.display); //这里一直display0是第一块屏；display1是第二块屏
            Intent secondIntent = new Intent();
            ComponentName cn = new ComponentName("com.autonavi.amapautp", "com.autonavi.amapauto.MainMapActivity");
            secondIntent.setComponent(cn); //该句很重要，不添加则无法推送到副屏
            secondIntent.addFlags(Intent.FLAG_ACTIVITY_MULTIPLE_TASK | Intent.FLAG_ACTIVITY_NEW_TASK);

            secondIntent.setData(Uri.parse("androidauto://naviPreview"));

            startActivity(secondIntent, options.toBundle()); // 使用ActivityOptions指定显示屏幕为Intent增加标志Intent.FLAG_ACTIVITY_MULTIPLE_TASK|Intent.FLAG_ACTIVITY_NEW_TASK
        } catch (Exception e) {
            Toast.makeText(this, "e：" + e.getMessage(), Toast.LENGTH_LONG).show();
        }

        finish();

    }


}